% MANDELBROT_01 Not optimised Mandelbrot function.
%
% Code revision with added optimization steps.
%
% HISTORY
%
%   20090701 KP - Initial version
%   20100506 KP - Allowing a center different from the origin
%
% AUTHOR
%
%   Koen Poppe, Department of Computer Science,
%   Katholieke Universiteit Leuven, Celestijnenlaan 200A,
%   B-3001 Heverlee, Belgium
%   Email:  Koen.Poppe@cs.kuleuven.be
%
function R_tilde=mandelbrot_01(center,radius,steps,maxiter)

% Variabelen alloceren
Z = zeros(steps,steps);
C = zeros(steps,steps);
R_tilde = zeros(steps,steps);

for r=0:maxiter
    for m=1:steps
        for n=1:steps
            if r == 0,
                C(m,n) = real(center)-radius+2*(n-1)*radius/(steps-1) ...
                    + i*(imag(center)-radius+2*(m-1)*radius/(steps-1));
                Z(m,n) = C(m,n);
                R_tilde(m,n) = maxiter;
            else
                if R_tilde(m,n) == maxiter,
                    Z(m,n) = Z(m,n)*Z(m,n) + C(m,n);
                    if abs(Z(m,n)) > 2,
                        R_tilde(m,n) = r;
                    end
                end
            end
        end
    end
end